home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / util / cli / sploinerwos.lha / source.lha / getopt.h < prev    next >
C/C++ Source or Header  |  1995-09-07  |  3KB  |  90 lines

  1. /*************************************************************************
  2. * getopt.h:    Header file for using getopt().
  3. * Author:    Daniel J. Barrett, barrett@cs.umass.edu
  4. * Status:    Public domain.
  5. *************************************************************************/
  6.  
  7.  
  8. #ifndef _GETOPT_H        /* Insure we #include me only once. */
  9. #define    _GETOPT_H 1
  10.  
  11.  
  12. /*************************************************************************
  13. * optarg
  14. * This variable is READ-ONLY!  Do not set its value yourself!
  15. *
  16. * If an option must be followed by a string, then optarg is a pointer
  17. * to that string.
  18. *
  19. * If an option should NOT be followed by an string, then optarg is
  20. * NOT DEFINED.  It is an error to reference optarg if no argument is
  21. * expected.
  22. *************************************************************************/
  23.  
  24.     extern char *optarg;
  25.  
  26. /*************************************************************************
  27. * optind
  28. * This variable is READ-ONLY!  Do not set its value yourself!
  29. *
  30. * After getopt() returns EOF, this variable contains the index of the
  31. * next unprocessed command-line argument.
  32. *
  33. * That is, argv[optind] is the first argument AFTER the options.
  34. *
  35. * If optind == argc-1, then there are no arguments after the options.
  36. *************************************************************************/
  37.  
  38.     extern int optind;
  39.  
  40. /*************************************************************************
  41. * optopt
  42. * This variable is READ-ONLY!  Do not set its value yourself!
  43. *
  44. * After each call of getopt(), this variable contains the option character
  45. * which was found on this call.
  46. *
  47. * Normally, you do not need to examine this variable because getopt()
  48. * returns the value of the character it read.
  49. * However, when getopt() discovers an illegal option, it returns the 
  50. * character '?'.  You now examine optopt to find the actual character
  51. * which getopt() read.
  52. *************************************************************************/
  53.  
  54.     extern int optopt;
  55.  
  56. /*************************************************************************
  57. * opterr
  58. * This variable is READ/WRITE.  You may set its value yourself.
  59. *
  60. * If opterr != 0, then getopt() will print its own error messages
  61. * on standard error (stderr).  Error messages are of the form:
  62. *
  63. *        -x: Illegal option.
  64. *        -x: An argument is required, but missing.
  65. *
  66. * assuming that the illegal option "-x" was read by getopt().
  67. *
  68. * If opterr == 0, these error messages are suppressed.
  69. * By default, opterr == 1, meaning that error messages are printed.
  70. *************************************************************************/
  71.  
  72.     extern int opterr;
  73.  
  74. /*************************************************************************
  75. * getopt()
  76. * The function prototype.
  77. *************************************************************************/
  78.  
  79.  
  80. #ifdef __STDC__
  81.       /*  extern int getopt(int argc, char *argv[], char *optionString); */
  82.      extern int getopt(int, char * const [], const char *);
  83. #else
  84.        extern int getopt();
  85. #endif /* __STDC__ */
  86.  
  87.  
  88. #endif /* _GETOPT_H */
  89.